package com.dustedpixels.jasmin.unit.z80.v2;
// Copyright DustedPixels.com 2008. All rights reserved.

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class Z80 {
  public boolean CLK;
  
  final class Regs {
    boolean WR_HI;
    boolean WR_LO;
    int REG_IN;
    int REG_OUT;
    int REG_OUT16;
    int IN_HI;
    int IN_LO;
    int OUT_HI;
    int OUT_LO;
    public int OUT16;
  
    int[] hiArray = new int[8];
    int[] loArray = new int[8];
  
    void clkHiTrigger() {
      if (WR_HI) {
        hiArray[REG_IN & 0x07] = IN_HI & 0xFF;
      }
      
      if (WR_LO) {
        loArray[REG_IN & 0x07] = IN_LO & 0xFF;
      }
    }
    
    void update() {
      int regOut = REG_OUT & 0x07;
      int regOut16 = REG_OUT16 & 0x07;
      
      OUT_HI = hiArray[regOut];
      OUT_LO = loArray[regOut];
  
      OUT16 = (hiArray[regOut16] << 8) | loArray[regOut16];
    }
  }
  
  public void updateMicroCode() {
    
  }
}
